
import { Menus } from 'src/menus/entities/menu.entity';
import { User } from 'src/user/entities/user.entity';
import {
    Column,
    CreateDateColumn,
    Entity,
    ManyToMany,
    PrimaryGeneratedColumn,
    UpdateDateColumn,
} from 'typeorm';

// Entity 装饰器  定义实体

@Entity('roles')
export class Roles {
    @PrimaryGeneratedColumn('uuid') // 设置主键
    id: string;

    @Column({
        type: 'varchar',
        length: 255,
        comment: '角色名',
    })
    name: string;


    @CreateDateColumn()
    createdAt: Date;

    @UpdateDateColumn()
    updatedAt: Date;


    // 多对多关系
    @ManyToMany(() => User, (user) => user.roles)
    user: User[]

    @ManyToMany(() => Menus, (menu) => menu.roles)
    menus: Menus[]
}
